package demo1;

/**
 * @author ：黄淼淳
 * @description：
 * @date ：2021/12/12 19:06
 */
public class Test {
    public static void main(String[] args) {
        Resource resource = new Resource();
       /* for (int i = 0; i < 10; i++) {
            new Thread(() -> {
                try {
                    resource.del();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }, "BB").start();
            new Thread(() -> {
                try {
                    resource.add();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }, "AA").start();
        }*/
        new Thread(() -> {
            try {
                for (int i = 0; i < 30; i++)
                    resource.increment();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }, "aa").start();
        new Thread(() -> {
            try {
                for (int i = 0; i < 30; i++)
                    resource.decrement();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }, "bb").start();
    }
}
